﻿#pragma once
#include "TUCamApi.h"

#ifdef _WIN64

#endif


class CameraManager
{
public:
	static CameraManager *GetInstance();
	~CameraManager();

	TUCAMRET InitApi(); /* Init the TUCAM API */	
	TUCAMRET UninitApi(); /* UnInit the TUCAM API */	
	TUCAMRET OpenCamera(UINT uiIdx); /* Open the camera by index number */	
	TUCAMRET CloseCamera(); /* Close the current camera */

	void SetAutoExposure();
	void SetExposure(double exposure);
	void ShowAverageGray();
	int CalculateAverageGray(const TUCAM_FRAME &frame);
	
	void GetParameter();
	void SetParameter();
	void SetParameter(const char *name, int type, double value, const char *stringValue);

	void CallBack();

	void Binning();
	void Histogram();
	void AutoLevel();
	void AreaWhiteBalance();
	void AreaWhiteBalance(bool value);
	void TimeStamp();
	void GpsTrigger();


	void OpenStream();
	void CloseStream();

	int GetResolutionCount();
	void SetResolution(int index);
	void TestCalculateHistogramData();


    char *GetCameraName();
    int GetVID();
    int GetPID();
    int GetCameraChannels();
    char *GetUSBType();
    char *GetFirmwareVersion();
    char *GetAPIVersion();
private:
	CameraManager();
	static CameraManager *instance;
	TUCAM_FRAME m_frame;      // The frame object

	TUCAM_INIT m_itApi; // SDK API initialized object
	TUCAM_OPEN m_opCam; // Open camera object	

	static void OnCallbackBuffer(void *userContext);
	void GetData();

	void SaveData(const char *path, unsigned char *data, int size);

	void StartCapture();
	void StopCapture();
	void CalculateHistogramData(const TUCAM_FRAME &frame);
};

